package cn.south.campus.business.controller;

import cn.south.campus.business.model.req.PartTimeJobReq;
import cn.south.campus.business.model.vo.PartTimeJobVo;
import cn.south.campus.business.service.PartTimeJobService;
import cn.south.campus.common.model.bo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 校园兼职表 前端控制器
 * </p>
 *
 * @author chow
 * @since 2025-03-27
 */
@RestController
@RequestMapping("/campus/partTimeJob")
@AllArgsConstructor
public class PartTimeJobController {

    private final PartTimeJobService partTimeJobService;

    @GetMapping("pageQuery")
    public Result<IPage<PartTimeJobVo>> pageQuery(PartTimeJobReq req) {
        return Result.success(partTimeJobService.pageQuery(req));
    }
    @GetMapping("myApply")
    public Result<IPage<PartTimeJobVo>> myApply(PartTimeJobReq req) {
        return Result.success(partTimeJobService.myApply(req));
    }

    @DeleteMapping("cancelApply/{id}")
    public Result<String> cancel(@PathVariable Long id) {
        partTimeJobService.cancelApply(id);
        return Result.success("取消成功");
    }

    @GetMapping("queryById/{id}")
    public Result<PartTimeJobVo> queryById(@PathVariable Long id) {
        return Result.success(partTimeJobService.queryById(id));
    }

    @PostMapping("apply/{id}")
    public Result<String> apply(@PathVariable Long id) {
        partTimeJobService.apply(id);
        return Result.success("申请成功");
    }
}
